package cn.ekuma.epos.datalogic.define.dao.pda;

import cn.ekuma.data.dao.ModifiedLogDAO;
import cn.ekuma.epos.datalogic.define.dao.ProductImageDAO;
import com.openbravo.bean.pda.ProductByteImage;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.TableDefinition;


public class ProductByteImageDAO extends ModifiedLogDAO<ProductByteImage>{
	ProductImageDAO productImage;
		public ProductByteImageDAO(I_Session s,ProductImageDAO productImage) {
	        super(s);
	        this.productImage=productImage;
	    }

	    @Override
	    public TableDefinition getTable() {
	        return productImage.getTableDefinition();
	    }

		@Override
		public void writeInsertValues(DataWrite dp, ProductByteImage obj)
				throws BasicException {
			dp.setString(1,obj.getId());
			dp.setString(2,obj.getProductId());
			dp.setString(3,obj.getM_Name());
			dp.setBytes(4, obj.getM_ImageDatas());
			dp.setTimestamp(5,obj.getLastModified());
			
		}

		@Override
		public Class getSuportClass() {
			return ProductByteImage.class;
		}

		@Override
		public ProductByteImage readValues(DataRead dr, ProductByteImage obj)
				throws BasicException {
			if(obj==null)
				obj=new ProductByteImage();
			obj.setId(dr.getString(1));
			obj.setProductId(dr.getString(2));
			obj.setM_Name(dr.getString(3));
			obj.setM_ImageDatas(dr.getBytes(4));
			obj.setLastModified(dr.getTimestamp(5));
			return obj;
		}
	}